package com.xzy.shop.web.servlet;

import com.xzy.shop.domain.User;
import com.xzy.shop.service.BuyedService;
import com.xzy.shop.service.impl.BuyedServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/buyed/*")
public class BuyedServlet extends BaseServlet {
    BuyedService service = new BuyedServiceImpl();
    //未支付订单
    public void countUnPay(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = (User) request.getSession().getAttribute("loginUser");
        int orders = service.findOrders(1, user.getUid() + "");
        writeValue(orders, response);
    }
    //运输中订单
    public void findtrans(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = (User) request.getSession().getAttribute("loginUser");
        int orders = service.findOrders(2, user.getUid() + "");
        writeValue(orders, response);
    }
    //未评价订单
    public void findUnMsg(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = (User) request.getSession().getAttribute("loginUser");
        int orders = service.findOrders(3, user.getUid() + "");
        writeValue(orders, response);
    }
    //喜欢的商品
    public void findLike(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = (User) request.getSession().getAttribute("loginUser");
        int orders = service.findOrders(4, user.getUid() + "");
        writeValue(orders, response);
    }
}
